package com.pozu.new_retail.service.impl;

import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.pozu.new_retail.dao.mapper.UpvoteMapper;
import com.pozu.new_retail.dao.model.Upvote;
import com.pozu.new_retail.service.UpvoteService;

@Service("upvoteService")
public class UpvoteServiceImpl implements UpvoteService {

	@Autowired
	private UpvoteMapper upvoteMapper;
	
	@Override
	public int queryCountByMap(HashMap<String, Object> map) {
		return upvoteMapper.queryCountByMap(map);
	}

	@Override
	public Upvote queryByMap(HashMap<String, Object> map) {
		return upvoteMapper.queryByMap(map);
	}

	@Override
	public Upvote saveUpvote(Upvote upvote) {
		
		long time = System.currentTimeMillis();
		
		upvote.setCreatedTime(time);
		upvote.setUpdatedTime(time);
		upvoteMapper.insertUpvote(upvote);
		
		return upvote;
	}

	@Override
	public int updateUpvote(Upvote upvote) {
		
		upvote.setUpdatedTime(System.currentTimeMillis());
		
		return upvoteMapper.updateUpvote(upvote);
	}

}
